exports.updateNotice = function (req, res) {

    var bodyParams = req.routeInfo.bodyParams;

    var newNotice = 0;

    //更新通知
    function updateNotice(cb) {
        var params = {
            update_where:"cn_id",
            cn_id:bodyParams.cn_id,
            cn_title: bodyParams.cn_title,
            cn_content: bodyParams.cn_content,
            cn_type: bodyParams.cn_type,
            cn_is_send: bodyParams.cn_is_send,
        }

        R.SEND_HTTP(
            req,
            res,
            {
                url: CORE_APIConfig.coreAPI.cmsNoticeUpdate.Request_Api_Url,
                method: 'POST',
                data: params
            },
            function (data) {
                console.log(data)
                cb();

            }
        )
    }

    //删除原有会员通知关系
    function deleteMemberNotice(cb) {
        var params = {
            delete_where:"cmn_cnid",
            cmn_cnid:bodyParams.cn_id,
            cmn_is_delete:1,
        }

        R.SEND_HTTP(
            req,
            res,
            {
                url: CORE_APIConfig.coreAPI.cmsMemberNoticeDelete.Request_Api_Url,
                method: 'POST',
                data: params
            },
            function (data) {
                console.log(data)
                cb();

            }
        )
    }

    //新增会员通知关系
    function addMemberNotice(cb) {
        //通知类型 0-系统 1-个人
        if (bodyParams.cn_type > 0) {
            //通知类型为个人，为每个对应人员生成通知消息关系
            F.SerialEach(bodyParams.cn_mid, function (item, index, callback) {

                var params = {
                    cmn_cmid: item,
                    cmn_cnid: bodyParams.cn_id,
                    cmn_is_view: 0,
                }
                console.log(params);
                R.SEND_HTTP(
                    req,
                    res,
                    {
                        url: CORE_APIConfig.coreAPI.cmsMemberNoticeAdd.Request_Api_Url,
                        method: 'POST',
                        data: params
                    },
                    function (data) {
                        console.log(data)
                        callback();

                    }
                )
            }, cb)
        } else {
            cb()
        }
    }

    F.Serial([
        updateNotice,
        deleteMemberNotice,
        addMemberNotice,
    ], () => {
        RES.successResponse(res);
    })

}